<?php

declare(strict_types=1);

namespace App\Controller\Index;

use App\Controller\BaseController;
use App\Request\Index\FrontBackRequest;
use App\Services\Index\FrontBackService;
use Hyperf\Context\Context;
use Hyperf\Di\Annotation\Inject;

class FrontBackController extends BaseController
{
    #[Inject]
    public FrontBackService $frontBackService;

    /**
     * Note - 前后台切换
     * DateTime 2024/8/20 19:01
     * User Admin
     * @param FrontBackRequest $request
     */
    public function switchFrontBack(FrontBackRequest $request)
    {
        $params = $this->request->post();
        $request->execute($params);

        $userinfo = Context::get('user');
        $uid = $userinfo['id'];
        $result = $this->frontBackService->switchFrontBack($uid, $params);
        return $this->return($result);
    }
}
